_onFocusPositionChanged(focusTracker) {
let rect = focusTracker.getCurrentRect();
this.setCursorLocation(focusTracker.currentWindow, rect.x, rect.y, rect.width, rect.height);
- this._updateLevelFromHints();
+ this._updateLevelFromHints(true);
}
_onDestroy() {
_onContentHintsChanged(controller, contentHint) {
this._contentHint = contentHint;
- this._updateLevelFromHints();
+ this._updateLevelFromHints(false);
}
- _updateLevelFromHints() {
+ _updateLevelFromHints(userInputHappened) {
// If the latch is enabled, avoid level changes
if (this._latched)
return;
if ((this._contentHint & Clutter.InputContentHintFlags.UPPERCASE) !== 0) {
this._setActiveLevel('shift');
- } else if (!this._surroundingTextId &&
- (this._contentHint &
- (Clutter.InputContentHintFlags.AUTO_CAPITALIZATION |
- Clutter.InputContentHintFlags.TITLECASE)) !== 0) {
+ return;
+ }
+
+ if ((this._contentHint &
+ (Clutter.InputContentHintFlags.AUTO_CAPITALIZATION |
+ Clutter.InputContentHintFlags.TITLECASE)) !== 0) {
+ if (this._surroundingTextId)
+ return;
+
this._surroundingTextId =
Main.inputMethod.connect('surrounding-text-set', () => {
const [text, cursor] = Main.inputMethod.getSurroundingText();
this._surroundingTextId = 0;
});
Main.inputMethod.request_surrounding();
+ return;
}
+
+ if (userInputHappened && this._currentPage === this._layers['shift'])
+ this._setActiveLevel('default');
}
_onKeyFocusChanged() {
button.connect('released', () => {
if (key.action === 'hide') {
this.close(true);
+ this._updateLevelFromHints(true);
} else if (key.action === 'languageMenu') {
this._popupLanguageMenu(button);
} else if (key.action === 'emoji') {
} else if (key.action === 'delete') {
this._keyboardController.toggleDelete(true);
this._keyboardController.toggleDelete(false);
+ this._updateLevelFromHints(true);
} else if (!this._longPressed && key.action === 'levelSwitch') {
this._setActiveLevel(key.level);
this._setLatched(
button.connect('keyval', (_actor, keyval) => {
this._keyboardController.keyvalPress(keyval);
this._keyboardController.keyvalRelease(keyval);
+ this._updateLevelFromHints(true);
});
} else {
button.connect('commit', (_actor, str) => {
this._keyboardController.commit(str, this._modifiers).then(() => {
this._disableAllModifiers();
- if (layout.mode === 'default' ||
- (layout.mode === 'latched' && !this._latched)) {
- if (this._contentHint !== 0)
- this._updateLevelFromHints();
- else
- this._setActiveLevel('default');
- }
+ this._updateLevelFromHints(true);
}).catch(console.error);
});
}